﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TeachingAffairsManagementSystem.WebControl;

namespace TeachingAffairsManagementSystem.UserControl.RightContent.Student
{
    public partial class MyLesson : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void GVMyLesson_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "DropLesson":
                    int currentIndex = Convert.ToInt32(e.CommandArgument);
                    // int s_id = Convert.ToInt32(GVMyLesson.DataKeys[currentIndex]["student_s_id"]);
                    int s_id = Convert.ToInt32(Session["id"]);
                    int l_id = Convert.ToInt32(GVMyLesson.DataKeys[currentIndex]["lesson_l_id"]);
                    int t_id = Convert.ToInt32(GVMyLesson.DataKeys[currentIndex]["lesson_teacher_t_id"]);
                    if (Operation.DropLesson(s_id, l_id, t_id))
                    {
                        Alert.Show("退出成功", AlertBox.Level.Success, true);
                        GVMyLesson.DataBind();
                    }
                    else
                    {
                        Alert.Show("退出失败", AlertBox.Level.Danger, true);
                    }

                    break;
            }
        }
    }
}